# coding: utf-8
import json
import time
import HFUTclockin
import requests
import os
import sys
import json
import time
from Crypto.Cipher import AES
import base64
import re
from urllib.parse import quote
requests = requests.session()
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36'
}
headers_form = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36',
    'Content-Type': 'application/x-www-form-urlencoded'
}
flag =True
def checktime():
    global flag
    time_now = time.strftime("%H:%M:%S", time.localtime())  # 刷新
    if time_now[:2] == "14":  # 此处设置每天定时的时间
        if flag:
            #print("run DAKA",time_now)
            rundaka()
            flag =False
    elif time_now[:2] =="23":
        flag = True

    time.sleep(600)
    checktime()


def rundaka():
    with open("account.json", "r", encoding="utf-8") as f:
        old_data = json.load(f)
        for key in old_data:

            print("key:", key)
            print("passwd",old_data[key]['passwd'])
            HFUTclockin.submit(key,old_data[key]['passwd'])
            HFUTclockin.logout()
            print("sleep-------------")
            time.sleep(20)


if __name__ == '__main__':
    checktime()
